package User;

public class ProxyUser {
    //代理类
    private User realUser;

    public ProxyUser(User user) {
        this.realUser = user;
    }
    public void borrowBook(String bookName){
        if(realUser instanceof NomalUser){
            ((NomalUser)realUser).borrowBook(bookName);
            //需要强转
        }else if(realUser instanceof AdminUser){
           // public void borrowBook(String bookName);
            System.out.println("您没有权限借阅书籍，请以普通⽤⼾的⽅式借阅书籍");
        }
    }
    public void addBook(String bookName){
        if(realUser instanceof AdminUser){
            ((AdminUser) realUser).addBook(bookName);
        }else if(realUser instanceof NomalUser){
            System.out.println("您没有权限上架书籍，请以管理员⽤⼾的⽅式上架书籍");
        }
    }
}
